package events {
	
	import org.flixel.FlxGroup;
	import org.flixel.FlxBasic;
	
	public class GameEventManager extends FlxGroup{
		
		private var lastAdded:GameEvent;
		
		public function GameEventManager(){
			lastAdded = null;
			visible = false;
		}
		
		override public function add(object:FlxBasic):FlxBasic{
			if (object is GameEvent){
				var gameEvent:GameEvent = object as GameEvent;
				gameEvent.parent = this;
			}
			return super.add(object);
		}
		
		public function queue(gameEvent:GameEvent):void{
			if (lastAdded != null){
				gameEvent.addDependancy(lastAdded);
			}
			lastAdded = gameEvent;
			add(gameEvent);
		}
	}
}
